#include "panelsplitterhandle.h"
#include <QColor>
#include <QPainter>

using namespace ExecTerminalImplNS;

const QColor DARK_COLOR(153, 153, 153);
const QColor MIDDLE_COLOR(227, 226, 226);
const QColor LIGHT_COLOR(255 , 255, 255);
const int TOP_WHITE_MARGIN = 1;

PanelSplitterHandle::PanelSplitterHandle(Qt::Orientation orientation, QSplitter * parent): QSplitterHandle(orientation, parent)
{

}

void PanelSplitterHandle::paintEvent(QPaintEvent * )
{
    QPainter painter(this);
    if (orientation() == Qt::Horizontal)
    {
        const int bottomY = height() - 1;
        const int rightX = width() - 1;
        painter.setPen(MIDDLE_COLOR);
        painter.drawLine(0, TOP_WHITE_MARGIN, 0, bottomY);
        painter.drawLine(rightX, TOP_WHITE_MARGIN, rightX, bottomY);
        painter.setPen(DARK_COLOR);
        painter.drawLine(1, TOP_WHITE_MARGIN, 1, bottomY);
        painter.fillRect(0, 0, width(), TOP_WHITE_MARGIN, LIGHT_COLOR);
    }
    else
    {
        const int rightX = width() - 1;
        painter.setPen(DARK_COLOR);
        painter.drawLine(0, 0, rightX, 0);
        painter.setPen(MIDDLE_COLOR);
        painter.drawLine(0, 1, rightX, 1);
        painter.setPen(LIGHT_COLOR);
        painter.drawLine(0, 2, rightX, 2);
    }
}

